package jpa4azure.type;

import javax.persistence.criteria.CriteriaQuery;


public class Key {

	protected String row;
	protected String partition;
	public static final String DEFAULT = "DEFAULT";

	public Key() {}
	
	public Key(String partition, String row) {
		this.partition = partition;
		this.row = row;
	}
	
	public Key(String row) {
		this.partition = DEFAULT;
		this.row = row;
	}
	
	public String getRow() {
		return row;
	}
	public String getPartition() {
		return partition;
	}
	
	public boolean equals(Object that) {
		if ( this == that ) return true;
		if ( !(that instanceof Key) ) return false;
		Key thatKey = (Key)that;
	
		return this.partition.equals(thatKey.getPartition()) &&
			this.row.equals(thatKey.getRow());
	}
	
	public String toString() {
		return "partition:" + partition + " " + "row:" + row;
	}

	@Override
	public int hashCode() {
		return (partition + row).hashCode();
	}

	//public <T> CriteriaQuery<T> find(Class<T> class1) { return null;}

}
